from rest_framework.views import exception_handler

# 异常响应处理器
def custom_exception_handler(exc, context):
    response = exception_handler(exc, context)
    if response is not None:
        response.data = {
            # "code": response.status_code,
            "code": 1,
            "message": response.status_text,
            "data": response.data
        }
    return response